package com.hnucm.c202001020214;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

public class ActivityCollector {
    //通过一个List来暂存Activity
    public static List<Activity> activities = new ArrayList<>();

    //向List中添加Activity
    public static void addActivity(Activity activity){
        activities.add(activity);
    }
    //从List中移除Activity
    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }

    //将List中储存的Activity全部销毁
    public static void finishAll(){
        for (Activity activity :activities){
            if (!activity.isFinishing()){
                activity.finish();
            }
        }
    }
}
